<?php

/*************************************************************************

	FILE INCLUDE

**************************************************************************/
include_once '../lib/Template.class.php';
$debug_mode_value = 0;



/*************************************************************************

	USER SCRIPT

***************************************************************************/
$userscript =<<<js
    <script type="text/javascript">
        <!--

        //-->
    </script>
js;


/*************************************************************************

		PAGE MAIN PROCESS

***************************************************************************/
(!empty($_POST['user_id']))? $user_id = $_POST['user_id'] : $user_id = "";
(!empty($_POST['user_pw']))? $user_pw = $_POST['user_pw'] : $user_pw = "";


print_rr($_POST);

$db->conn();
$arr=$db->fetch("select * from user_tb where USER_ID = '$user_id' AND USER_PW = '$user_pw'");
$db->close();
if(!empty($arr)){
	$_SESSION['user_id']=$user_id;
	$_SESSION['user_cd']=$arr['USER_CD'];
	$_SESSION['user_lv']=$arr['USER_LV'];
	$_SESSION['user_nm']=$arr['USER_NM'];
	$db->conn();
	$work1=$db->fetch("select IF(max(STATUS_DT_3)>max(STATUS_DT_6),max(STATUS_DT_3),max(STATUS_DT_6)) as last_date,
				SUM(IF(STATUS_REGISTER_3=$arr[USER_CD],1,0)) + SUM(IF(STATUS_REGISTER_6=$arr[USER_CD],1,0)) as work_total
				from cluster_work_tb
				where STATUS_REGISTER_3 = $arr[USER_CD] OR STATUS_REGISTER_6 =$arr[USER_CD]");

	if(!empty($work1['work_total'])){

		$work2=$db->fetch("select SUM(IF(STATUS_REGISTER_3=$arr[USER_CD],1,0)) + SUM(IF(STATUS_REGISTER_6=$arr[USER_CD],1,0)) as work_last
							from cluster_work_tb
							where (STATUS_REGISTER_3 = $arr[USER_CD] AND STATUS_DT_3 = '$work1[last_date]')
							OR (STATUS_REGISTER_6 =$arr[USER_CD] AND STATUS_DT_6 = '$work1[last_date]')");

		$_SESSION['work_total']=$work1['work_total'];
		$_SESSION['work_last']=$work2['work_last'];

	}else{
		$_SESSION['work_total']=0;
		$_SESSION['work_last']=0;
	}
	$db->close();

	if($arr['USER_LV']==1){
		print_rr($_SESSION);
		$JSClass->replace("./SynonymValidation.php");
	}else{
		$JSClass->replace("./SynonymValidation.php");
	}

}else{
	$JSClass->msg_replace("Check your account!","./login.php");
}



/*************************************************************************

	TEMPLATE PROCESS

***************************************************************************/



/*************************************************************************

	AJAX FUNCTION : Template_ function

***************************************************************************/



















?>
